{include file="common/head"/}
<style>
  .bondus .layui-input{display:inline;width:80%}
</style>

<div class="layui-fluid"><div class="layui-card"><div class="layui-card-body">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>规则配置</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
    
    <blockquote class="layui-elem-quote">
        <a>购买规则</a>
    </blockquote>
      <div class="layui-form-item bondus">
        <div class="layui-inline">
            <label class="layui-form-label">FOS币售价</label>
                <div class="layui-input-inline">
                <input type="text" lay-verify="required" name="fos_price" placeholder="FOS币固定售价" value="{$info.fos_price}" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style='width:160px;'>分销关系解除时限</label>
                <div class="layui-input-inline">
                <input type="text" lay-verify="required" name="fos_out_time" placeholder="分销关系解除时限(小时)" value="{$info.fos_out_time}" class="layui-input">(小时)
            </div>
        </div>
        <!--<div class="layui-inline">
            <label class="layui-form-label">最多购买</label>
                <div class="layui-input-inline">
                <input type="text" name="buy_max" lay-verify="required" placeholder="最多购买(颗)" value="{$info.buy_max}" class="layui-input">
            </div>
        </div>-->
      </div>
	  
	  <blockquote class="layui-elem-quote">
        <a>签到规则</a>
    </blockquote>
      <div class="layui-form-item bondus">
        <div class="layui-inline">
            <label class="layui-form-label">签到送</label>
                <div class="layui-input-inline">
                <input type="text" lay-verify="required" name="sign_tcsn" placeholder="送TCSN(枚)" value="{$info.sign_tcsn}" class="layui-input"> (枚)
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style='width:160px;'>连续7天送</label>
                <div class="layui-input-inline">
                <input type="text" lay-verify="required" name="sign_7_tcsn" placeholder="送TCSN(枚)" value="{$info.sign_7_tcsn}" class="layui-input"> (枚)
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">连续30天送</label>
                <div class="layui-input-inline">
                <input type="text" name="sign_30_tcsn" lay-verify="required" placeholder="送TCSN(枚)" value="{$info.sign_30_tcsn}" class="layui-input"> (枚)
            </div>
        </div>
      </div>
	  
        <blockquote class="layui-elem-quote">
            <a >分销规则</a>
       </blockquote>
        <div class="layui-form-item">
            <table class="layui-table" id="list" lay-filter="list"></table>
        </div>
        
       <blockquote class="layui-elem-quote">
            <a >升级规则 (新会员注册购买时触发升级规则)</a>
       </blockquote>
       <div class="layui-form-item">
            <table class="layui-table" id="upgrade" lay-filter="upgrade"></table>
        </div>
        
        <!--<blockquote class="layui-elem-quote">
            <a >代数奖</a>
       </blockquote>
       <div class="layui-form-item bondus">
            <div class="layui-inline">
              <label class="layui-form-label">一代</label>
              <div class="layui-input-inline">
                <input type="tel" name="bonus1" value='{$info.bonus1}' autocomplete="off" class="layui-input">%
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">二代</label>
              <div class="layui-input-inline">
                <input type="text" name="bonus2" value='{$info.bonus2}' autocomplete="off" class="layui-input">%
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">三代</label>
              <div class="layui-input-inline">
                <input type="text" name="bonus3" value='{$info.bonus3}' autocomplete="off" class="layui-input">%
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">四代</label>
              <div class="layui-input-inline">
                <input type="text" name="bonus4" value='{$info.bonus4}' autocomplete="off" class="layui-input">%
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">五代</label>
              <div class="layui-input-inline">
                <input type="text" name="bonus5" value='{$info.bonus5}' autocomplete="off" class="layui-input">%
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">六代</label>
              <div class="layui-input-inline">
                <input type="text" name="bonus6" value='{$info.bonus6}' autocomplete="off" class="layui-input">%
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">七代</label>
              <div class="layui-input-inline">
                <input type="text" name="bonus7" value='{$info.bonus7}' autocomplete="off" class="layui-input">%
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">八代</label>
              <div class="layui-input-inline">
                <input type="text" name="bonus8" value='{$info.bonus8}' autocomplete="off" class="layui-input">%
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">无限代</label>
              <div class="layui-input-inline">
                <input type="text" name="bonus9" value='{$info.bonus9}' autocomplete="off" class="layui-input">%
              </div>
            </div>
        </div>-->
        
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <button type="reset" class="layui-btn layui-btn-primary">{:lang('reset')}</button>
                <!--<button type="button" class="layui-btn layui-btn-normal" id="trySend">测试发送</button>-->
            </div>
        </div>
    </form>
</div>
</div>
</div>


<script type="text/html" id="bonus">
    {{# if(d.bonus==999){ }}
      无限代
    {{# }else{  }}
      {{d.bonus}}
    {{# } }}
</script>

<script type="text/html" id="level">
    F{{d.id}}
</script>


<script type="text/html" id="action">
   // <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
</script>
{include file="common/foot"/}
<script>
    layui.use(['form', 'layer', 'table'], function () {
        var form = layui.form,layer = layui.layer,$= layui.jquery, table = layui.table;
        
        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: '{:url("get_rule")}',
            method: 'post',
            page: false,  //关闭分页展示
            cols: [[
                {field: 'level', title: '会员级别', width: 160},
                {field: 'earning', title: '每日收益(%)', width: 160, edit:true},
                {field: 'amount', title: '买入限额(枚)', width: 160, edit:true},
                //{field: 'frezz_count', title: '提现压(颗)', width: 160, edit:true},
                //{field: 'bonus', title: '可拿代数', width: 160, templet:'#bonus', edit:true}
                //{title: '操作', width: 160, align: 'center', toolbar: '#action'}
            ]]
        });
       
         
        var tableIn1 = table.render({
            id: 'upgrade',
            elem: '#upgrade',
            url: '{:url("get_upgrade")}',
            method: 'post',
            page: false,  //关闭分页展示
            cols: [[ 
                {field: 'id', title: '会员级别', width: 140,templet:'#level',edit:true},
                {field: 'lev_1_count', title: '推荐一级F1个数', width: 140, edit:true},
                {field: 'lev_2_count', title: '推荐二级F1个数', width: 140, edit:true},
                {field: 'lev_3_count', title: '推荐三级F1个数', width: 140, edit:true},
                {field: 'memo', title: '说明', width: 160, edit:true}
            ]]
        });
        
        table.on('edit(upgrade)', function(obj){
            console.log(obj)
            $.post('set_upgrade_val', {'id':obj.data.id, 'key':obj.field, 'val':obj.value}, function(data){
                layer.msg('设置成功!');
            })
        })
        
        table.on('edit(list)', function(obj){
            $.post('set_rule_val', {'id':obj.data.id, 'key':obj.field, 'val':obj.value}, function(data){
                layer.msg('设置成功!');
            })
        })
        
        
        
        //发送测试邮件
        $('#trySend').click(function(){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var email = $('#test_eamil').val();
            $.post("{:url('trySend')}",{email:email},function(res){
                layer.close(loading);
                if(res.code > 0){
                    layer.msg(res.msg,{time:1800});
                }else{
                    layer.msg(res.msg,{time:1800});
                }
            });
        });
        //提交监听
        form.on('submit(submit)', function (data) {
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post("{:url('system/rule')}",data.field,function(res){
                layer.close(loading);
                if(res.code > 0){
                    layer.msg(res.msg,{icon: 1, time: 1000},function(){
                        location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{icon: 2, time: 1000});
                }
            });
        })
        
    })
</script>
</body>
</html>